package com.stars.home.vmodel

import android.app.Application
import android.view.View
import androidx.lifecycle.MutableLiveData
import com.stars.home.activity.DriverDetailsActivity
import com.stars.home.fragment.AccountBillFragment
import com.stars.home.model.AmountCount
import com.stars.home.model.User
import com.stars.home.utils.net.NetEngine
import com.trailer.base.base.BRRepository
import com.trailer.base.base.BRViewModel
import com.trailer.base.net.IResp
import com.trailer.base.utils.B
import com.trailer.base.utils.UiSwitch

/**
 *
 *on 2020/9/18
 */
class DriverOrderListVModel(application: Application) : BRViewModel<BRRepository>(application) {



    val user: MutableLiveData<User?> = MutableLiveData(User.get())
    var info: MutableLiveData<AmountCount> = MutableLiveData<AmountCount>()

    var fragment: AccountBillFragment? = null
    var order_state:String? = "0"//订单状态


    fun toDetails(order_id:String?){


        UiSwitch.bundle(repository().context, DriverDetailsActivity::class.java,
                B().putString("order_id",order_id).ok())


    }

    fun isShowChat(state:Int,type:Int):Int{

        if(state==-1||state==0||state==1||state==6){
            return View.GONE
        }
        if(type==1||type==2||type==3){
            return View.GONE
        }
        return View.VISIBLE
    }
    fun isShowPhone(state:Int):Int{

        if(state==-1||state==0||state==1||state==6){
            return View.GONE
        }
        return View.VISIBLE
    }


    fun isShowButName(status:Int?):String{

        if(status==6){
            return "已完成"
        }
        return "进行中"

    }


    override fun apiFunc(): suspend () -> IResp<*> {


        return { NetEngine.service.orderList(order_state, "10", repository().page)
        }
    }
}
